<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use sjaakp\taggable\TagEditor;
use yii\helpers\Url;


/* @var $this yii\web\View */
/* @var $model common\models\Article */
/* @var $per common\models\Article */
/* @var $tag common\models\Article */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="article-form">

    <?php $form = ActiveForm::begin(
        [
            'id' => 'mend-form',
            'options' => ['class' => 'form-horizontal'],
            'fieldConfig' => [
                'template' => "{label}\n<div class=\"col-lg-8\">{input}{hint}</div>\n<div class=\"col-lg-8\">{error}</div>",
                'labelOptions' => ['class' => 'col-lg-2 control-label'],
            ],
        ]
    ); ?>


    <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
    <?= $form->field($model, 'label_img')->widget('common\widgets\file_upload\FileUpload',[
                    'config'=>[
                        //图片上传的一些配置，不写调用默认配置
                    ]
                ]) ?>
    <?= $form->field($model, 'editorTags')->widget(TagEditor::className(), [
        'tagEditorOptions' => [
            'autocomplete' => [
                'source' => Url::toRoute(['tag/suggest'])
            ],
        ]
    ])?>

    <?= $form->field($model, 'content')->widget(\yii\redactor\widgets\Redactor::className(), [
        'clientOptions' => [
//            'imageManagerJson' => ['/redactor/upload/image-json'],
//            'imageUpload' => ['/redactor/upload/image'],
//            'fileUpload' => ['/redactor/upload/file'],
            'lang' => 'zh_cn',
            'plugins' => ['clips', 'fontcolor', 'imagemanager']
        ]
    ]) ?>

    <?= $form->field($model, 'sys_category_id')->dropDownList(\yii\helpers\ArrayHelper::map($category, 'id', 'name')) ?>

    <div class="form-group">
        <label for="" class="col-lg-4"></label>
        <?= Html::submitButton($model->isNewRecord ? '发布' : '修改', ['id' => 'abc', 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>

